package com.lxg.service.impl;

import com.lxg.dao.AccountDao;
import com.lxg.service.AccountService;
import com.lxg.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 陆小根
 * date: 2022/04/27
 * Description:
 */

@Service
public class AccountServiceImpl implements AccountService {

  @Autowired
  private AccountDao accountDao;
  @Autowired
  private LogService logService;
  @Transactional
  public void transfer(String out,String in ,Double money) {
    try{
      accountDao.outMoney(out,money);
      int i = 1 / 0;
      accountDao.inMoney(in,money);
    }finally {
      logService.log(out,in,money);
    }
  }
}
